package cn.dengta.webapp.trade.model;

import cn.dengta.common.model.ValueProxy;
import cn.dengta.context.model.LabelI18nProxy;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

import static cn.dengta.context.model.TradeEnumI18nKey.*;

@Getter
public enum Flow implements LabelI18nProxy<Flow, Integer> {
	/** 支出 */
	CONSUME(-1, FLOW_CONSUME),
	/** 不变 */
	NONE(0, FLOW_NONE),
	/** 收入 */
	INCOME(1, FLOW_INCOME);

	@EnumValue
	public Integer value;
	final ValueProxy<Flow, Integer> proxy;

	// 构造函数，枚举类型只能为私有
	Flow(Integer value, String label) {
		this.value = value;
		this.proxy = new ValueProxy<>(this, value, label);
	}

	public static Flow[] getValues() {
		return ValueProxy.getCachedArray(Flow.class, Flow::values);
	}

	public static Flow of(Integer value) {
		return NONE.getValueOf(value);
	}

}
